package gao.xaiolei.dao;

import java.util.List;

import gao.xaiolei.enity.TaskAttached;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository("ITaskAttachedDao")
public interface ITaskAttachedDao extends JpaRepository<TaskAttached, String> {

	// 根据任务Id来获得任务附件信息
	@Query(value = "from TaskAttached where taskId = :taskId")
	public List<TaskAttached> findByTaskId(
            @Param("taskId") String taskId);

//	// 根据任务Id删除任务附件
//	@Modifying
//	// update或者delete操作，在更新或者删除操作时，此注解必须加
//	@Query(value = "delete TaskAttached where taskId = :taskId")
//	public void deleteByTaskId(@Param("taskId") String taskId);

//	// 根据文件uuid来删除任务附件
//	@Modifying
//	// update或者delete操作，在更新或者删除操作时，此注解必须加
//	@Query(value = "delete TaskAttached where TA_UUID = :TA_UUID")
//	public void deleteByUuid(@Param("TA_UUID") String TA_UUID);

	// 根据任务Id来获得任务附件数量
	@Query(value = "select count(*) from TaskAttached where taskId = :taskId")
	public int getCountByTaskId(@Param("taskId") String taskId);

	// 获取该附件的任务Id
	@Query(value = "select taskId from TaskAttached where id = :id")
	public String getTaskIdOf(@Param("id") String id);

}
